<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">

            <script type='text/javascript' src='media/js/quadraMask.js'></script>
            <script type='text/javascript' src='media/js/validateMultipleNumber.js'></script>

            <h:form id="form" enctype="multipart/form-data">
                <br/>
                <h2 class="title">Relatório de Geral</h2>
                <p:growl id="messages" showDetail="false" autoUpdate="true"  /> 
                <br/>
                <p:panel id="cessaoPanel" styleClass="container_24 clearfix">

                    <h4 class="title">Fator de Localização</h4>

                    <p:outputLabel value="Distrito" styleClass="grid_3" for="dInput" />
                    <p:inputText id="dInput" styleClass="grid_4" 
                                 value="#{managerPesquisarImovel.imovel.inscricaoCadastralD}" />

                    <p:outputLabel value="Setor" styleClass="grid_3" for="sInput" />
                    <p:inputText id="sInput" styleClass="grid_4" 
                                 value="#{managerPesquisarImovel.imovel.inscricaoCadastralS}" />

                    <!--                    <p:outputLabel value="Quadra" styleClass="grid_3" for="qInput" />
                                        <p:inputText id="qInput" styleClass="grid_4" 
                                                     value="#{managerPesquisarImovel.imovel.inscricaoCadastralQuadra}" />-->

                    <p:outputLabel value="Quadra" styleClass="grid_3" for="qInput" />
                    <p:inputText id="qInput" styleClass="grid_4" 
                                 value="#{managerPesquisarImovel.inscricaoCadastralQuadra}"
                                 onkeydown="jQuery(this).validateMultipleNumber();"/>
                    <p:watermark value="1,2;3-5" for="qInput" rendered="true"/>
                    <div class="clear-both" />

                    <p:outputLabel value="Lote" styleClass="grid_3" for="lInput" />
                    <p:inputText id="lInput" styleClass="grid_4" 
                                 value="#{managerPesquisarImovel.imovel.inscricaoCadastralLote}" />

                    <p:outputLabel value="Unidade" styleClass="grid_3" for="uInput" />
                    <p:inputText id="uInput" styleClass="grid_4" 
                                 value="#{managerPesquisarImovel.imovel.inscricaoCadastralUnid}" />
                    <div class="clear-both" />
                </p:panel>

                <p:panel id="geralPanel" styleClass="container_24 clearfix">
                    <h4 class="title">Geral</h4>

                    <p:outputLabel value="Uso do Imóvel" styleClass="grid_3 usoImovelLabelRelatorioGeral"/>
                    <div class="grid_4 omega">
                        <p:selectOneMenu value="#{managerPesquisarImovel.imovel.usoImovel}" panelStyle="width: 150px">
                            <f:selectItem itemValue="#{null}" itemLabel=""/>
                            <f:selectItems value="#{managerUtilitario.usoImovel}"/>
                        </p:selectOneMenu>
                    </div>

                    <p:outputLabel value="Rip" styleClass="grid_3 alpha"/>
                    <div class="grid_5 omega">
                        <p:selectOneMenu value="#{managerPesquisarImovel.imovel.rip}" panelStyle="width: 150px">
                            <f:selectItem itemValue="#{null}" itemLabel=""/>
                            <f:selectItem itemValue="TRUE" itemLabel="Possuem"/>
                            <f:selectItem itemValue="FALSE" itemLabel="Não Possuem"/>
                        </p:selectOneMenu>
                    </div>

                    <p:outputLabel value="Documento" styleClass="grid_3"/>
                    <div class="grid_5">
                        <p:selectOneMenu value="#{managerPesquisarImovel.imovel.tipoDocumentoImovel}" panelStyle="width: 400px">
                            <f:selectItem itemValue="#{null}" itemLabel=""/>
                            <f:selectItems value="#{managerUtilitario.tipoDocumentoImovel}"/>
                        </p:selectOneMenu>
                    </div>
                    <div class="clear"/>

                    <p:outputLabel value="Composição" styleClass="grid_3 composicaoLabelRelatorioGeral"/>
                    <div class="grid_4 omega">
                        <p:selectOneMenu value="#{managerPesquisarImovel.proprietario.composicaoFamiliar}" panelStyle="width: 150px">
                            <f:selectItem itemValue="#{null}" itemLabel=""/>
                            <f:selectItems value="#{managerUtilitario.composicaoFamiliar}"/>
                        </p:selectOneMenu>
                    </div>

                    <p:outputLabel value="Renda" styleClass="grid_3 alpha"/>
                    <div class="grid_5">
                        <p:selectOneMenu value="#{managerPesquisarImovel.proprietario.rendaFamiliar}" panelStyle="width: 150px">
                            <f:selectItem itemValue="#{null}" itemLabel=""/>
                            <f:selectItems value="#{managerUtilitario.rendaFamiliar}"/>
                        </p:selectOneMenu>
                    </div>
                    <div class="clear"/>

                    <p:outputLabel value="IPTU" styleClass="grid_3"/>
                    <div class="grid_4 omega">
                        <p:selectOneMenu value="#{managerPesquisarImovel.imovel.insetoIptu}" panelStyle="width: 150px">
                            <f:selectItem itemValue="#{null}" itemLabel=""/>
                            <f:selectItem itemValue="#{true}" itemLabel="Contribui"/>
                            <f:selectItem itemValue="#{false}" itemLabel="Isento"/>
                        </p:selectOneMenu>
                    </div>

                    <p:outputLabel value="STU" styleClass="grid_3 alpha"/>
                    <div class="grid_5">
                        <p:selectOneMenu value="#{managerPesquisarImovel.imovel.insetoTsu}" panelStyle="width: 150px">
                            <f:selectItem itemValue="#{null}" itemLabel=""/>
                            <f:selectItem itemValue="#{true}" itemLabel="Contribui"/>
                            <f:selectItem itemValue="#{false}" itemLabel="Isento"/>
                        </p:selectOneMenu>
                    </div>
                    <div class="clear"/>

                </p:panel>

                <p:panel id="programasPanel" styleClass="container_24 clearfix">

                    <h4 class="title">Programas Sociais</h4>

                    <p:outputLabel value="Minha Casa Minha Vida" styleClass="grid_6"/>
                    <div class="grid_5">
                        <p:selectOneMenu value="#{managerPesquisarImovel.proprietario.minhaCasaMinhaVida}" panelStyle="width: 150px">
                            <f:selectItem itemValue="#{null}" itemLabel=""/>
                            <f:selectItem itemValue="#{true}" itemLabel="Participa"/>
                            <f:selectItem itemValue="#{false}" itemLabel="Não participa"/>
                        </p:selectOneMenu>
                    </div>

                    <p:outputLabel value="Bolsa Família" styleClass="grid_5"/>
                    <div class="grid_5">
                        <p:selectOneMenu value="#{managerPesquisarImovel.proprietario.bolsaFamilia}" panelStyle="width: 150px">
                            <f:selectItem itemValue="#{null}" itemLabel=""/>
                            <f:selectItem itemValue="#{true}" itemLabel="Participa"/>
                            <f:selectItem itemValue="#{false}" itemLabel="Não participa"/>
                        </p:selectOneMenu>
                    </div>
                    <div class="clear"/>
                </p:panel>

                <p:panel id="addressPanel" styleClass="container_24 clearfix">

                    <h4 class="title">Endereço</h4>

                    <p:outputLabel value="Número" styleClass="grid_3"/>
                    <div class="grid_4">
                        <p:selectOneMenu value="#{managerPesquisarImovel.imovelComNumero}" panelStyle="width: 150px">
                            <f:selectItem itemValue="#{null}" itemLabel=""/>
                            <f:selectItem itemValue="#{true}" itemLabel="Possui"/>
                            <f:selectItem itemValue="#{false}" itemLabel="Não possui"/>

                            <p:ajax event="change" update=":form:numeroInputText" listener="#{managerPesquisarImovel.verificarNumeroEnderecoImovel}"/>
                        </p:selectOneMenu>
                    </div>
                    <div class="clear"/>

                    <p:outputLabel value="CEP" styleClass="grid_3" for="cepInputMask" />
                    <p:inputMask id="cepInputMask" styleClass="grid_4" mask="99.999-999"
                                 value="#{managerPesquisarImovel.endereco.cep}" />
                    <div class="clear-both" />

                    <p:outputLabel value="Número" styleClass="grid_3" for="numeroInputText" />
                    <p:inputText id="numeroInputText" styleClass="grid_2" 
                                 disabled="#{managerPesquisarImovel.imovelComNumero ne null and !managerPesquisarImovel.imovelComNumero}"
                                 value="#{managerPesquisarImovel.endereco.numero}" />

                    <p:outputLabel value="Logradouro" styleClass="grid_4 alpha" for="logradouroInputText" />
                    <p:inputText id="logradouroInputText" styleClass="grid_13"
                                 value="#{managerPesquisarImovel.endereco.logradouro}" />
                    <div class="clear-both" />

                    <p:outputLabel value="Bairro" styleClass="grid_3" for="bairroInputText" />
                    <p:autoComplete id="bairroInputText" styleClass="grid_19"  dropdown="true" converter="bairroconverter"   
                                    var="bairro" itemLabel="#{bairro.nome}" multiple="true" itemValue="#{bairro}"
                                    scrollHeight="200" forceSelection="true"
                                    completeMethod="#{managerPesquisarImovel.autocompleteMultipleBairro}">
                        <p:ajax event="itemSelect" listener="#{managerPesquisarImovel.adicionarBairroSelecionado}" process="@this"/>
                        <p:ajax event="itemUnselect" listener="#{managerPesquisarImovel.removerBairroSelecionado}" process="@this"/>
                    </p:autoComplete>

                </p:panel>

                <p:panel id="anexoPanel" styleClass="container_24 clearfix">

                    <h4 class="title">Anexos</h4>

                    <p:outputLabel value="Anexo" styleClass="grid_3"/>
                    <div class="grid_4">
                        <p:selectOneMenu value="#{managerPesquisarImovel.imovelComAnexo}" panelStyle="width: 150px">
                            <f:selectItem itemValue="#{null}" itemLabel=""/>
                            <f:selectItem itemValue="#{true}" itemLabel="Possui"/>
                            <f:selectItem itemValue="#{false}" itemLabel="Não possui"/>
                        </p:selectOneMenu>
                    </div>

                    <p:outputLabel value="Croqui" styleClass="grid_3"/>
                    <div class="grid_4">
                        <p:selectOneMenu value="#{managerPesquisarImovel.imovelComCroqui}" panelStyle="width: 150px">
                            <f:selectItem itemValue="#{null}" itemLabel=""/>
                            <f:selectItem itemValue="#{true}" itemLabel="Possui"/>
                            <f:selectItem itemValue="#{false}" itemLabel="Não possui"/>
                        </p:selectOneMenu>
                    </div>
                    <div class="clear"/>
                </p:panel>

                <br/>
                <div class="buttonAction">

                    <p:commandButton  
                        title="Imprimir" icon="ui-icon-print"
                        actionListener="#{managerPesquisarImovel.pesquisarRelatorioGeral()}"
                        value="Imprimir"/>
                    <p:commandButton  
                        title="Limpar" icon="ui-icon-clean" update="@form"
                        actionListener="#{managerPesquisarImovel.init()}"
                        value="Limpar"/>

                    <p:commandButton id="imprimirCommandButton" style="display: none"
                                     ajax="false" update="@form" widgetVar="imprimir"
                                     onclick="this.form.target='_blank'"
                                     actionListener="#{managerPesquisarImovel.relatorioGeral()}"/>
                </div>
                <br/><br/>

            </h:form>
        </ui:define>
    </ui:composition>
</html>
